import { fileURLToPath, URL } from 'node:url';

import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import vueJsx from '@vitejs/plugin-vue-jsx';
import vueDevTools from 'vite-plugin-vue-devtools';

// https://vite.dev/config/
export default defineConfig({
  plugins: [vue(), vueJsx()],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
  server: {
    proxy: {
      // 示例代理配置，根据需求调整
      '/api': {
        target: 'https://jlhome.yulecheng.icu/api', // 目标服务器地址
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''), // 可选路径重写
      },

      // '/admin': {
      //   target: 'https://jlapi.yulecheng.icu/admin', // 目标服务器地址
      //   changeOrigin: true,
      //   rewrite: (path) => path.replace(/^\/admin/, '') // 可选路径重写
      // }
    },
  },
});
